< previous page page_291 next page >

Page 291
z0311-01.gif
Figure 10.9
Calculating the dimensions of a snowflake generator.
other than 60 degrees. Figure 10.8 shows a generator that turns 45 degrees, 90 degrees, and then 45 degrees again.
More generally, if you want the first turn to be q degrees, the second should be 2 * q, and the third should be q again. Suppose the total length of the segment should be R, and the length of the shorter pieces is r. Then Figure 10.9 shows that R = 2 * r + 2 * r * Cos(q). Solving this equation for r, you get r = R / (2 * (1 + Cos(q))). Using these facts, you can write a routine to initialize the generator for any angle q .
Example program Flake lets you build snowflakes. Enter the level of recursion you want and the first angle the generator should use. Then click the Go button to have the program draw the appropriate snowflake. Figure 10.10 shows snowflakes created with generators that start with different angles.
Animated Snowflakes
Example program FlakeAn1 displays animated snowflakes. The program starts by displaying a depth zero snowflake. It then gradually pulls the midpoints of each edge out until they reach their correct positions for a level-one snowflake. Figure 10.11 shows three frames in the sequence between a level-zero snowflake and a level-one snowflake.
z0311-02.gif
Figure 10.10
Depth four snowflakes with generators beginning with 45, 80, and 90 degree turns.

 
< previous page page_291 next page >